package suibian;

import java.io.IOException;
import java.util.Scanner;

public class FootballLeagueMain {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        League league = new League();

        try {
            league.loadTeamsFromFile("src/suibian/text.txt");

            System.out.println("请输入本轮比赛结果（格式：主队名 客队名 主队得分 客队得分）：");
            String input = scanner.nextLine();
            String[] parts = input.split("\\s+");
            String homeTeamName = parts[0];
            String awayTeamName = parts[1];
            int homeGoals = Integer.parseInt(parts[2]);
            int awayGoals = Integer.parseInt(parts[3]);

            league.updateMatchResult(homeTeamName, awayTeamName, homeGoals, awayGoals);
            league.sortTeams();
            league.displayTeams();
            league.saveTeamsToFile("src/suibian/text.txt");

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            scanner.close();
        }
    }
}

